package com.fbs.wowo.manage.mapper;

import com.fbs.wowo.manage.entity.UserLogin;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface UserLoginMapper {
    @Delete({
        "delete from user_login",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @InsertProvider(type=UserLoginSqlProvider.class, method="insertSelective")
    int insertSelective(UserLogin record);

    @Select({
        "select",
        "id, user_id, tel, verify_code, create_time, is_reg, login_type, status",
        "from user_login",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
        @Result(column="verify_code", property="verifyCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="is_reg", property="isReg", jdbcType=JdbcType.TINYINT),
        @Result(column="login_type", property="loginType", jdbcType=JdbcType.TINYINT),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT)
    })
    UserLogin selectByPrimaryKey(String id);

    @UpdateProvider(type=UserLoginSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UserLogin record);

    /**
     * 根据手机号查找
     * @param tel 电话号
     * @return UserLogin
     */
    @Select({
            "select",
            "id, user_id, tel, verify_code, create_time, is_reg, login_type, status",
            "from user_login",
            "where tel = #{tel,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
            @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
            @Result(column="verify_code", property="verifyCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="is_reg", property="isReg", jdbcType=JdbcType.TINYINT),
            @Result(column="login_type", property="loginType", jdbcType=JdbcType.TINYINT),
            @Result(column="status", property="status", jdbcType=JdbcType.TINYINT)
    })
    UserLogin findByTel(String tel);
}